package com.woniuxy.portal.common.enumeration;

public enum UserStatus {

    INACTIVE(0, "未激活"), ACTIVE(1, "激活"), BLOCKED(2, "锁定");

    private Integer key;
    private String value;
    
    UserStatus(Integer key, String value) {
        this.key = key;
        this.value = value;
    }

    public Integer getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    /**
     * 通过键找到枚举
     */
    public static UserStatus matchKey(Integer key) {
        UserStatus result = null;
        for (UserStatus val : values()) {
            if (val.getKey().equals(key)) {
                result = val;
                break;
            }
        }
        return result;
    }

    /**
     * 通过值找到枚举
     */
    public static UserStatus matchValue(String value) {
        UserStatus result = null;
        for (UserStatus val : values()) {
            if (val.getValue().equals(value)) {
                result = val;
                break;
            }
        }
        return result;
    }
}